package cn.tedu.ex;


import java.io.*;

//测试 jdk新特性
public class TestIO {
    public static void main(String[] args){
//        method();//字节流读取
        method2();//字节流读取
    }

    public static void method2() {
        try (InputStream in = new BufferedInputStream(new FileInputStream("D:\\iotest\\1.txt"));){
            int b = 0;
            while ((b = in.read()) != -1){
                System.out.print((char) b);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

    public static void method() {
        InputStream in = null;
        try {
            in = new BufferedInputStream(new FileInputStream("D:\\iotest\\1.txt"));
            int b = 0;
            while ((b = in.read()) != -1){
                System.out.print((char) b);
            }
        }catch (ArithmeticException | IOException e){
            e.printStackTrace();
        }finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}
